<template>
    <div style="border: 1px solid #ccc">
      <md-editor v-model="text" @onHtmlChanged="saveHtml()"/>
      <p>{{list.name}}</p>
    </div>
</template>
<script lang='ts'>
import '@wangeditor/editor/dist/css/style.css' // 引入 css
import {useRoute} from "vue-router"
import { ref, onMounted } from 'vue'
import axios from "../../utils/request"
 import MdEditor from 'md-editor-v3';
 import 'md-editor-v3/lib/style.css';
export default {
    components: { MdEditor },
  data() { return { text: '' }; },
  methods: { saveHtml(h: string) { console.log(h) }},
  setup() {
      const list:any=ref([])
        const route=useRoute()
        const id=route.params.id as string
    // 模拟 ajax 异步获取内容
    onMounted(() => {
        axios.post('/api/detail',{id}).then(res=>{
        list.value=res.data.data
        console.log(res.data.data)
    })
    })
    return {
      list,
    };
  }
}
</script>    


